export const getMouseProductName = (productName?: string) => {
  // https://L2A51.yjx2012.com

  if (productName?.includes("SM809")) {
    return "SM809";
  }

  return productName;
};

export const getImgPath = () => {
  const isProd = process.env.NODE_ENV === "production";

  // SSR/SSG 或 Node 环境：无法读取 window，给出安全默认
  if (typeof window === "undefined") {
    return isProd ? "." : "";
  }

  const pathname = window.location.pathname || "";
  // 兼容 /detail、/detail/、/detail/xxx、file:///.../detail/index.html 等
  const onDetail =
    pathname.endsWith("/detail") ||
    pathname.endsWith("/detail/") ||
    pathname.includes("/detail/");

  const prefix = onDetail ? ".." : ".";

  // 生产环境返回相对前缀用于静态导出；开发环境保持空串以不干扰 dev server
  return isProd ? prefix : "";
};
